<script type="text/javascript">
$(document).ready(function(){
	  $('#ItemCategoryId').live('change', function() {
	    if($(this).val().length != 0) {
		    console.log("categoryId: " + $(this).val())
	      $.getJSON('/asset/items/get_models_ajax',
	                  {catId: $(this).val()},
	                  function(types) {
	                    if(types !== null) {
	                      populateList(types);
	                    }
	        });
	      }
	    });
	});
	 
	function populateList(types) {
	  var options = '';
	 
	  $.each(types, function(index, type) {
	    options += '<option value="' + index + '">' + type.toUpperCase() + '</option>';
	  });
	  $('#ItemTypeId').html(options);
	  $('#types').show();
	 
	}
	
	$(function() {
		$( "#ItemDate" ).datepicker();
	});
	$(document).ready(function(){
		<!--
		var currentTime = new Date()
		var month = currentTime.getMonth() + 1
		var day = currentTime.getDate()
		var year = currentTime.getFullYear()
		$( "#ItemDate" ).val(month + "/" + day + "/" + year)
		//-->
	});
	$(function() {
		$( "#OwnershipDate" ).datepicker();
	});
	$(document).ready(function(){
		<!--
		var currentTime = new Date()
		var month = currentTime.getMonth() + 1
		var day = currentTime.getDate()
		var year = currentTime.getFullYear()
		$( "#OwnershipDate" ).val(month + "/" + day + "/" + year)
		//-->
	});
	$(function() {
		$( "#LocationDate" ).datepicker();
	});
	$(document).ready(function(){
		<!--
		var currentTime = new Date()
		var month = currentTime.getMonth() + 1
		var day = currentTime.getDate()
		var year = currentTime.getFullYear()
		$( "#LocationDate" ).val(month + "/" + day + "/" + year)
		//-->
	});
</script>
<div class="top-bar">
	<h1>Asset</h1>
	<div class="breadcrumbs">
		<a href="/asset">Laman Utama</a> / <a href="#">Asset</a> / <a href="#">Pendaftaran
			Baru</a>
	</div>
	<br />
	<div class="select-bar" style="border-bottom: 0px; margin-bottom: 5px;"></div>
</div>
<div class="table">
	<img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
	<img src="img/bg-th-right.gif" width="7" height="7" alt=""
		class="right" />
		<?php echo $this->Form->create('Item', array('enctype' => 'multipart/form-data'));?>
	<table class="listing form" cellpadding="0" cellspacing="0">
		<tr>
			<th class="full" colspan="2">Pendaftaran Asset Baru</th>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Kew.Pa.2</strong></td>
			<td class="last"><?php echo $this->Form->input('q_pa',array('div' => false, 'label'=>''));?>
			</td>
		</tr>
		<tr>
			<td class="first" width="172"><strong>Kod Nasional</strong></td>
			<td class="last"><?php echo $this->Form->input('national_code',array('label'=>''));?>
			</td>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Kategori</strong></td>
			<td class="last"><?php echo $this->Form->input('category_id',array('empty' => '[SILA PILIH]','div' => false,'label'=>''));?>
			</td>
		</tr>
		<tr>
			<td class="first""><strong>Jenis</strong></td>
			<td class="last"><?php echo '<div id="types" style="display: none;">';
			echo $this->Form->input('type_id',array('empty' => '[SILA PILIH]','div' => false,'label'=>''));
			echo '</div>';?>
			</td>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Nama Model</strong></td>
			<td class="last"><?php echo $this->Form->input('name',array('label'=>''));?>
			</td>
		</tr>
		<tr>
			<td class="first"><strong>Buatan</strong></td>
			<td class="last"><?php echo $this->Form->input('origin_id',array('label'=>'','empty' => '[SILA PILIH]','div' => false));?>
			</td>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Pembekal</strong></td>
			<td class="last"><?php echo $this->Form->input('supplier_id',array('label'=>'','empty' => '[SILA PILIH]','div' => false));?>
			</td>
		</tr>
		<tr>
			<td class="first"><strong>Jenis Perolehan</strong></td>
			<td class="last"><?php echo $this->Form->input('ownership_id',array('label'=>'','empty' => '[SILA PILIH]','div' => false));?>
			</td>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Tarikh Perolehan</strong></td>
			<td class="last"><input type="text" name="data[Item][ownership_date]"
				id="OwnershipDate">
			</td>
		</tr>
		<tr>
			<td class="first"><strong>No Siri Pembuat</strong></td>
			<td class="last"><?php echo $this->Form->input('manufacturer_serial_no',array('label'=>''));?>
			</td>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Harga Perolehan</strong></td>
			<td class="last"><?php echo $this->Form->input('price',array('label'=>'','value'=>"0.00"));?>
			</td>
		</tr>
		<tr>
			<td class="first"><strong>Tarikh Penerimaan</strong></td>
			<td class="last"><input type="text" name="data[Item][received_date]"
				id="ItemDate"></td>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Tempoh Jaminan</strong></td>
			<td class="last"><input name="data[Item][warranty_period][period]"
				type="text" value="" id="ItemWarrantyPeriod"> <select
				name="data[Item][warranty_period][type]"
				id="ItemWarrantyPeriod[type]">
					<option value="0">day</option>
					<option value="1">month</option>
					<option value="2">year</option>
			</select></td>
		</tr>
		<tr>
			<td class="first"><label for="FileImage"><strong>Image </strong></label></td>
			<td class="last"><input type="file" name="data[File][image]" id="FileImage" />
			</td>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Catatan</strong></td>
			<td class="last"><?php echo $this->Form->input('remarks',array('label'=>''));?>
			</td>
		</tr>
	</table>

	 <!-- <div class="optional">
		    <?php echo $this->Form->label('File/image', 'Image',array('enctype' => 'multipart/form-data')); ?>
    	    <?php echo $this->Form->file('image_url'); ?>
    	
    		<?php echo $this->Form->label('image1', 'Image1'); ?>
			<?php echo $this->Form->file('File.image1'); ?>
			
			<input type="file" name="data[File][image]" id="FileImage" />
			<?php echo $this->Form->label('image1', 'Image1'); ?>
			<?php echo $this->Form->file('File.image1'); ?>
			
			<?php
        		echo $this->Form->create('Item', array('type' => 'file'));
        		echo $this->Form->input('Item.name');
        		echo $this->Form->input('Upload.0.file', array('type' => 'file'));
        		echo $this->Form->input('Upload.1.file', array('type' => 'file'));
        		echo $this->Form->end('Save Application and Two Uploads');
    		?>
    		
    		<?php
        		echo $this->Form->create('Upload', array('type' => 'file'));
        		echo $this->Form->input('file', array('type' => 'file'));
        		echo $this->Form->end('Simpan Gambar');
    		?>
	      </div>  -->
	      
	     
	<table class="listing form" cellpadding="0" cellspacing="0">
		<tr>
			<th class="full" colspan="2">Penempatan</th>
		</tr>
		<tr class="bg">
			<td class="first"><strong>Lokasi</strong></td>
			<td class="last">
			<?=$this->Form->input('Location.district_id',array('empty' => '[PILIH]','div' => false,'label'=>''));?>
			</td>
		</tr>
		<tr>
			<td class="first"><strong>Tarikh</strong></td>
			<td class="last"><input type="hidden" id="LocationDate" maxlength="255" name="data[Location][date]" style="width:85px">
			</td>
		</tr>		
		<tr class="bg">
			<td class="first"><strong>Nama Pegawai</strong></td>
			<td class="last"><?=$this->Form->input('Location.pic',array("label"=>false));?>
			</td>
		</tr>
	</table>
	<?php echo $this->Form->end(__('Submit', true));?>
</div>
<p>&nbsp;</p>

<div class="clear"></div>
